﻿using System;
using System.Collections.Generic;
using System.Windows.Input;
using System.Windows.Shell;
using Fluffy.Library.Mvvm;

namespace Fluffy.Library.DocumentContainer
{
	public abstract class DocumentViewModelBase : ViewModelBase
	{
		private double _progressValue;
		private string _progressMessage;
		private TaskbarItemProgressState _progressState = TaskbarItemProgressState.None;

		public double ProgressValue
		{
			get { return _progressValue; }
			protected set
			{
				if (_progressValue == value)
					return;

				_progressValue = value;
				OnPropertyChanged("ProgressValue");
			}
		}

		public TaskbarItemProgressState ProgressState
		{
			get { return _progressState; }
			protected set
			{
				if (_progressState == value)
					return;

				_progressState = value;
				OnPropertyChanged("ProgressState");
			}
		}

		public string ProgressMessage
		{
			get { return _progressMessage; }
			protected set
			{
				if (_progressMessage == value)
					return;

				_progressMessage = value;
				OnPropertyChanged("ProgressMessage");
			}
		}

		public abstract ICommand CutCommand { get; }
		public abstract ICommand CopyCommand { get; }
		public abstract ICommand PasteCommand { get; }

		public abstract ICommand SaveCommand { get; }
		public abstract ICommand SaveAsCommand { get; }

		public abstract CommandsContainer Menu1 { get; }
		public abstract CommandsContainer Menu2 { get; }
		public abstract CommandsContainer Menu3 { get; }

		public abstract void Close();
	}

	public class CommandsContainer
	{
		private readonly string _header;
		private readonly List<IMenuContent> _children = new List<IMenuContent>();

		public CommandsContainer(string header = null)
		{
			_header = header;
		}

		public string Header
		{
			get { return _header; }
		}

		public bool IsVisible
		{
			get { return !string.IsNullOrEmpty(_header); }
		}

		public List<IMenuContent> Children
		{
			get { return _children; }
		}
	}

	public class SeparatorItem : IMenuContent { }

	public class CommandItem : IMenuContent
	{
		private readonly string _header;
		private readonly ICommand _command;

		public CommandItem(string header, ICommand command)
		{
			if (string.IsNullOrEmpty(header)) 
				throw new ArgumentNullException("header");
			if (command == null)
				throw new ArgumentNullException("command");

			_header = header;
			_command = command;
		}

		public ICommand Command
		{
			get { return _command; }
		}

		public string Header
		{
			get { return _header; }
		}
	}

	public interface IMenuContent { }
}
